<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<script src="/qiandao/Public/js/jquery-1.8.2.min.js"></script>

	<title>抽奖</title>
	<link rel="stylesheet" type="text/css" href="/qiandao/Public/css/normalize.css" />
	<link rel="stylesheet" type="text/css" href="/qiandao/Public/css/demo.css">
	<link rel="stylesheet" type="text/css" href="/qiandao/Public/css/lottery.css">
	<script src="/qiandao/Public/js/prefixfree.min.js"></script>
	<!--[if IE]>
		<script src="http://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	<![endif]-->
</head>
<body>


	<div class="stars"></div>

        <div class="lotteryList">
            <ul>
                <?php if(is_array($userInfoList)): $i = 0; $__LIST__ = $userInfoList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$userInfo): $mod = ($i % 2 );++$i;?><li>
                        <div style="width:100px;height:20px;text-shadow:1px 1px greenyellow;"><?php echo ($userInfo["name"]); ?> </div><div><?php echo ($userInfo["phone"]); ?> </div>
                    </li><?php endforeach; endif; else: echo "" ;endif; ?>

                <?php if(is_array($userInfoList)): $i = 0; $__LIST__ = $userInfoList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$userInfo): $mod = ($i % 2 );++$i;?><li>
                       <div style="width:100px;height:20px;text-shadow:1px 1px greenyellow;"><?php echo ($userInfo["name"]); ?> </div><div><?php echo ($userInfo["phone"]); ?> </div>
                    </li><?php endforeach; endif; else: echo "" ;endif; ?>
            </ul>
        </div>

        <div class="lotteryTool">
            <a class="next" style="display:none;">下一轮</a>

            <!--<a class="restart"  style="display:none;">重抽</a>-->

            <a class="stop" >停止</a>
        </div>





	<div class="tagBall">



        <div class="lotteryUserList" id="lotteryResult">
                <a class="nextLottery">下一轮</a>
        </div>
        <a class="start">开始</a>







        <?php if(is_array($userInfoList)): $i = 0; $__LIST__ = $userInfoList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$userInfo): $mod = ($i % 2 );++$i;?><img class="tag" src="/qiandao/Uploads/<?php echo ($userInfo["pic"]); ?>" lotteryUniqid="<?php echo ($userInfo["uniqid"]); ?>" phone="<?php echo ($userInfo["phone"]); ?>" username="<?php echo ($userInfo["name"]); ?>"/><?php endforeach; endif; else: echo "" ;endif; ?>


    </div>




    <script src="/qiandao/Public/js/init.js"></script>



    <script>

        var is_lottery = false;
        $(".stop").click(function(){
            $(this).hide();
            is_lottery = false;
            $.post("<?php echo U('Home/Index/getLotteryUser');?>",{lotteryId:<?php echo (session('lotteryId')); ?>},function(data){
                if(data.result == 1){
                    tags.forEach(function(){
                        this.end(data.lotteryUniqid,data.name);
                    });


                } else if(data.result == 0){
                    tags.forEach(function(){
                        this.end(0);
                    });
                    $(".nextLottery").show("slow");
                } else{
                    tags.forEach(function(){
                        this.end(0);
                    });
                    console.log(data);
                    alert('所有奖项已经抽完');
                }
                clearInterval(timer);

                $(this).hide();
                //$(".next").show();
                $(".restart").show();
               // $(".stop").hide();
                $(".lotteryList").hide();
                $(".lotteryUserList").show();


            })

        });

        $(".start").click(function(){
            is_lottery = true;
            $(this).hide();
           // $('.stop').show();
            lotteryList();
            startLottery("<?php echo U('Home/Index/lottery');?>");
        });

//        $(".next").click(function(){
//            $(".lotteryUserBox").remove();
//            $(".lotteryUserList").hide();
//            $("this").hide();
//
//            $('.stop').show();
//            lotteryList();
//            startLottery();
//        });
//
//        $(".restart").click(function(){
//            $(".lotteryUserBox").remove();
//            $(".lotteryUserList").hide();
//            $(".next").hide();
//            $(this).hide();
//            $('.stop').show();
//            lotteryList();
//            startLottery();
//        });


//        $(".lotteryUserList").on('click','.lotteryUser',function(){
//            $(this).siblings(".selectUser").show();
//            var uniqid = $(this).attr('uniqid');
//            var lotteryId = $(this).attr('lotteryid');
//            //abandonUserList[lotteryId].push(uniqid)
//            console.log(abandonUserList);
//
//        });
//        $(".lotteryUserList").on('click',".selectUser",function(){
//            var uniqid = $(this).siblings(".lotteryUser").attr('uniqid');
//            var lotteryId = $(this).siblings(".lotteryUser").attr('lotteryid');
//           // var index = abandonUserList[lotteryId].indexOf(uniqid);
//           // abandonUserList[lotteryId].splice(index,1);
//            console.log(abandonUserList);
//           // $(this).hide();
//        });


        $(".lotteryUserList").on("mouseenter",".lotteryImg",function(){
            console.log("in");
            $(".lotteryControl").slideDown("slow");
        });
        $(".lotteryUserList").on("mouseleave",".lotteryControl",function(){
            console.log("out");
            $(this).fadeOut("slow");
        });

        $(".lotteryUserList").on("click",".next",function(){
            is_lottery = true;
            $(".lotteryImg").remove();
            $(".lotteryControl").remove();

            $(".lotteryUserList").hide();

            $(this).hide();

            lotteryList();
            startLottery();
        });

        $(".lotteryUserList").on("click",".nextLottery",function(){
             is_lottery = true;
            $(".lotteryUserList").hide();
            $(this).hide();

            lotteryList();
            startLottery();
        });

        $(".lotteryUserList").on("click",".abandence",function(){
            is_lottery = true;
            var uniqId = $(".lotteryImg img").attr("uniqid");
            console.log($(".lotteryImg"));
            $.post("<?php echo U('Home/Index/abandon');?>",{uniqId:uniqId},function(){
                $(".lotteryImg").remove();
                $(".lotteryControl").remove();
            });

            $(".lotteryUserList").hide();

            lotteryList();
            startLottery();
        });

        $(".lotteryTool").hover(function(){
            if(is_lottery){
                $(".stop").show();
            }
           // $(".stop").animate({width:"210px"}).animate({width:"200px"});
        },function(){
            $(".stop").hide();
        })

    </script>

</body>
</html>